<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta charset="utf-8">
<title>查询</title>

    <script type="text/jscript" src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js"></script>
</head>

<body>

<section class="main">
    <div class="setup_modular">
        <div class="setup_footer">
            <a href="${pageContext.request.contextPath}/resume/getResume" class="footer_btn sure_btn">新增</a>
        </div>
    </div>

        	<table>
            	<tr>
                    <th>ID</th>
                    <th>姓名</th>
                    <th>电话</th>
                    <th>地址</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${resumes}" var="resumes">
                <tr>
                    <td>${resumes.id}</td>
                    <td>${resumes.name}</td>
                    <td>${resumes.phone}</td>
                    <td>${resumes.address}</td>
                    <td class="tabel_operate">
                        <a href="${pageContext.request.contextPath}/resume/getResume?id=${resumes.id}" >编辑</a>

                        <a href="javascript:deleteById(${resumes.id});" title="">删除</a>
                    </td>
                </tr>
                </c:forEach>
            </table>

</body>
<script type="text/javascript">

    function deleteById(id){
        var ctx="${pageContext.request.contextPath}";

        //第二步：验证数据，这里需要从数据库调数据，我们就用到了ajax
        $.ajax({
            url:ctx+"/resume/delete",//请求地址
            data:{id:id},//提交的数据
            type:"POST",//提交的方式
            dataType:"TEXT", //返回类型 TEXT字符串 JSON XML
            success:function(data){
                alert(data)
                //开始之前要去空格，用trim()
                if(data.trim()=="success")
                {
                    window.location.href = ctx+"/resume/queryAll";
                }
                else{
                    alert("失败");
                }
            }
        })
    }
</script>
</html>
